package org.openkoala.koala.popup.generatecode;

public enum DBType {
	
	MySQL {
		@Override
		public String getDBDriver() {
			return "com.mysql.jdbc.Driver";
		}

		@Override
		public String getConnectionURL() {
			return "jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=UTF-8";
		}

		@Override
		public String getDBName() {
			return "MySQL";
		}
	},
	
	Oracle {
		@Override
		public String getDBDriver() {
			return "oracle.jdbc.OracleDriver";
		}

		@Override
		public String getConnectionURL() {
			return "jdbc:oracle:thin:@localhost:1521:oa";
		}

		@Override
		public String getDBName() {
			return "Oracle";
		}
	},
	
	SQL_Server_2008{

		@Override
		public String getDBDriver() {
			return "net.sourceforge.jtds.jdbc.Driver";
		}

		@Override
		public String getConnectionURL() {
			return "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_name";
		}

		@Override
		public String getDBName() {
			return "SQL_Server";
		}
		
	},
	
	Other{

		@Override
		public String getDBDriver() {
			return "";
		}

		@Override
		public String getConnectionURL() {
			return "";
		}

		@Override
		public String getDBName() {
			return "Other";
		}
		
	};
	
	public abstract String getDBDriver();
	
	public abstract String getConnectionURL();
	
	public abstract String getDBName();
	
	public static DBType getDBTypeByName(String name){
		if(name.equals(DBType.MySQL.getDBName())){
			return DBType.MySQL;
		}
		if(name.equals(DBType.Oracle.getDBName())){
			return DBType.Oracle;
		}
		if(name.equals(DBType.SQL_Server_2008.getDBName())){
			return DBType.SQL_Server_2008;
		}
		return DBType.Other;
	}
}
